package com.vandzi.android.androidcode;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.util.Linkify;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class HomeActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home);
		// ======================================================================================
		// set links to images
		ImageView img = (ImageView) findViewById(R.id.imageViewMojAndroid);
		img.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_VIEW);
				intent.addCategory(Intent.CATEGORY_BROWSABLE);
				intent.setData(Uri.parse("http://mojandroid.sk"));
				startActivity(intent);
			}
		});

		img = (ImageView) findViewById(R.id.imageViewMojAndroid);
		img.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_VIEW);
				intent.addCategory(Intent.CATEGORY_BROWSABLE);
				intent.setData(Uri.parse("http://www.mojandroid.sk/"));
				startActivity(intent);
			}
		});

		img = (ImageView) findViewById(R.id.imageViewAppsRulezz);
		img.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_VIEW);
				intent.addCategory(Intent.CATEGORY_BROWSABLE);
				intent.setData(Uri.parse("http://apps.rulezz.sk/2011/"));
				startActivity(intent);
			}
		});

		img = (ImageView) findViewById(R.id.imageViewHtc);
		img.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_VIEW);
				intent.addCategory(Intent.CATEGORY_BROWSABLE);
				intent.setData(Uri.parse("http://www.htcfans.cz/"));
				startActivity(intent);
			}
		});

		img = (ImageView) findViewById(R.id.imageViewSygic);
		img.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_VIEW);
				intent.addCategory(Intent.CATEGORY_BROWSABLE);
				intent.setData(Uri.parse("http://www.sygic.com/en"));
				startActivity(intent);
			}
		});

		img = (ImageView) findViewById(R.id.imageViewSmartAdds);
		img.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_VIEW);
				intent.addCategory(Intent.CATEGORY_BROWSABLE);
				intent.setData(Uri.parse("http://www.smartads.sk/"));
				startActivity(intent);
			}
		});

		TextView myWebLink = (TextView) findViewById(R.id.textViewWebPage);
		Linkify.addLinks(myWebLink, Linkify.WEB_URLS);
		

		// ======================================================================================
		// buttons listeners

		/*
		 * Button login = (Button) findViewById(R.id.buttonLogin);
		 * login.setOnClickListener(new OnClickListener() {
		 * 
		 * @Override public void onClick(View arg0) { final Dialog loginDialog =
		 * new Dialog(HomeActivity.this);
		 * loginDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		 * loginDialog.setContentView(R.layout.login);
		 * loginDialog.getWindow().setLayout(LayoutParams.FILL_PARENT,
		 * LayoutParams.WRAP_CONTENT); loginDialog.show();
		 * 
		 * 
		 * final EditText login = (EditText)
		 * loginDialog.findViewById(R.id.editTextLogin); final EditText password
		 * = (EditText) loginDialog.findViewById(R.id.editTextPassword);
		 * 
		 * // login button Button loginButton = (Button) loginDialog
		 * .findViewById(R.id.buttonLoginAction);
		 * loginButton.setOnClickListener(new OnClickListener() {
		 * 
		 * @Override public void onClick(View arg0) {
		 * AndroidCodeService.login(login.getText().toString(),
		 * password.getText().toString()); loginDialog.dismiss(); } }); // login
		 * button Button cancelLoginButton = (Button) loginDialog
		 * .findViewById(R.id.buttonCancelLoginAction);
		 * cancelLoginButton.setOnClickListener(new OnClickListener() {
		 * 
		 * @Override public void onClick(View arg0) { loginDialog.dismiss();
		 * 
		 * } });
		 * 
		 * } });
		 * 
		 * Button registration = (Button) findViewById(R.id.buttonRegistration);
		 * registration.setOnClickListener(new OnClickListener() {
		 * 
		 * @Override public void onClick(View arg0) { Intent intent = new
		 * Intent(HomeActivity.this, RegistrationActivity.class);
		 * startActivity(intent);
		 * 
		 * } });
		 */

	}
}
